﻿using Kingdee.BOS.App.Data;
using Kingdee.BOS.Contracts;
using Kingdee.BOS.Core.Report;
using Kingdee.BOS.Orm.DataEntity;
using Kingdee.BOS.Util;
using Kingdee.K3.FIN.AR.App.Report;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;

namespace LiMinCRMPlugin
{
    [Description("二开应收款汇总表  增加销售主体")]
    [HotUpdate]
    public class ARSumRepService : ARSumReportService
    {
        private string CostCalBilltTableNames;

        public override void BuilderReportSqlAndTempTable(IRptParams filter, string tableName)
        {
            IDBService dbService = Kingdee.BOS.App.ServiceHelper.GetService<IDBService>();
            CostCalBilltTableNames = dbService.CreateTemporaryTableName(this.Context);
            base.BuilderReportSqlAndTempTable(filter, CostCalBilltTableNames);
            DynamicObject customFilter = filter.FilterParameter.CustomFilter;

            string sql = string.Format(@"select * into {0} from {1}",tableName,CostCalBilltTableNames);
            DBUtils.Execute(this.Context, sql.ToString());

        }
        public override ReportHeader GetReportHeaders(IRptParams filter)
        {
            ReportHeader report = base.GetReportHeaders(filter);
            return report;

        }
        public override void CloseReport()
        {
            if (string.IsNullOrWhiteSpace(CostCalBilltTableNames))
            {
                return;
            }
            IDBService dbService = Kingdee.BOS.App.ServiceHelper.GetService<IDBService>();

            dbService.DeleteTemporaryTableName(this.Context, new string[1] { CostCalBilltTableNames });
            base.CloseReport();

        }
    }
}
